package com.google.code.sapwcrawler.urlfilter;
import java.net.URL;
public class LimitURLFilter extends URLFilterDecorator
{
	private int limit 	= 100000;
	private int current = 0;
	public synchronized void setLimit(int v)
	{
		this.limit = v;
	}
	
	private synchronized boolean isLimitReached()
	{
		return limit <= current;
	}
	
	private synchronized void inc()
	{
		current++;
	}
	
	@Override
	public boolean isDownloadableURL(URL v)
	{
		if(!isLimitReached())
		{
			if(getUrlFilter().isDownloadableURL(v))
			{
				inc();
				return true;
			}
		}
		return false;
	}
}
